﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ASPNETVN.PORTAL;
using ASPNETVN.PORTAL.Components.Share;
using ASPNETVN.PORTAL.Modules.CMS.Components;
using ASPNETVN.PORTAL.Components.Configuration;
using ASPNETVN.PORTAL.Components.UI;
using ASPNETVN.PORTAL.Components.Configuration.Settings;
using ASPNETVN.PORTAL.Components.UI.DataTypes;
using ASPNETVN.PORTAL.Components.Security;
using ASPNETVN.PORTAL.Components.Helpers;
using ASPNETVN.PORTAL.Modules.CMS;
using System.Collections;

namespace MTL.Modules.HOME
{
    public partial class Main : PortalModuleControl
    {
        private Guid moduleIDSP = new Guid("f72e2c40-a29f-4b4e-bfc8-efe916ec0cf4");
        private Guid moduleIDTT = new Guid("1bc5e570-a012-4459-b014-72bede17347f"); 

        protected string GetUrl(int itemID)
        {
            Guid tabID = Guid.Empty;
            PortalDataSet ds = PortalConfiguration.GetPortalDataSet();

            foreach (PortalDataSet.TabRow tab in ds.Tab.Rows)
            {
                foreach (PortalDataSet.ModuleRow module in tab.GetModuleRows())
                {
                    if (module.ID == moduleIDSP || module.ID == moduleIDTT )
                    {
                        return string.Format("~/Default.aspx?tabid={0}&mid={1}&itemid={2}&page=detail", tab.ID, module.ID, itemID);
                    }
                }
            }
            return string.Format("~/Default.aspx");
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                //Lay khuon mau chinh xac                
                int categoryID = 128000100;
                // Get one type item for home.
                DataList1.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleIDSP, categoryID, "ONE");
                DataList1.DataBind();

                //Lay tin tuc Minh Thinh Loi                
                categoryID = 128000103;                
                // Get one type item for home.
                Repeater1.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleIDTT, categoryID, "ONE");
                Repeater1.DataBind();
                // Get two type item for home.
                Repeater2.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleIDTT, categoryID, "TWO");
                Repeater2.DataBind();

                //Lay tin tuc lien quan                
                categoryID = 128000104;   
                // Get one type item for home.
                Repeater3.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleIDTT, categoryID, "ONE");
                Repeater3.DataBind();
                // Get two type item for home.
                Repeater4.DataSource = ASPNETVN.PORTAL.Modules.CMS.Components.Item.GetItemsByDisplayType(moduleIDTT, categoryID, "TWO");
                Repeater4.DataBind();
            }
        }
    }
}